<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    <link rel="stylesheet" th:href="@{./layui/css/layui.css}" media="all">
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <script th:src="@{./layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/china.js}"></script>
</head>
<body class="childrenBody">

<div>
    <div class="layui-bg-gray" style="padding: 30px;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <div class="layui-panel" style="width: 800px">
                    <fieldset class="layui-elem-field layui-field-title">
                        <legend style="font-weight: bold">新冠疫情数据在线实时显示(<span
                                th:text="${#dates.format(chinaTotal.updateTime,'yyyy-MM-dd HH:mm')}"></span>)
                        </legend>
                    </fieldset>
                    <!--div 一个面板--数据显示-->
                    <div style="margin-left: 10px">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-bg-red layui-btn-lg"
                                    th:text="'累计确诊：'+${chinaTotal.confirm}"></button>
                            <button type="button" class="layui-btn layui-bg-orange layui-btn-lg"
                                    th:text="'累计输入：'+${chinaTotal.input}"></button>
                            <button type="button" class="layui-btn layui-btn-lg"
                                    th:text="'累计治愈：'+${chinaTotal.heal}"></button>
                            <button type="button" class="layui-btn layui-bg-cyan layui-btn-lg"
                                    th:text="'累计死亡：'+${chinaTotal.dead}"></button>
                            <button type="button" class="layui-btn layui-bg-red layui-btn-lg"
                                    th:text="'现有确诊：'+${chinaTotal.confirm-chinaTotal.dead-chinaTotal.heal}"></button>
                        </div>
                    <!-- 中国疫情地图，为echarts准备的dom -->
                    <div id="main" style="width: 790px; height: 750px;"></div>

                    </div>
                </div>
            </div>
            <div class="layui-col-md6" style="width: 467px; right: -180px;position:relative">
                <div class="layui-panel">
                    <!-- 面板2：轮播图 -->
                    <div class="layui-carousel" id="test1" lay-filter="test1">
                        <div carousel-item="">
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo1.jpg}"></div>
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo2.jpg}"></div>
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo3.jpg}"></div>
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo4.jpg}"></div>
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo5.jpg}"></div>
                            <div><img style="width: 100%;height: 100%;" th:src="@{/images/lunbo6.jpg}"></div>
                        </div>
                    </div>
                    <!-- 新闻时间线 -->
                    <div style="padding-right: 10px">
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                            <legend style="font-weight: bold">抗疫时报</legend>
                        </fieldset>
                        <ul class="layui-timeline">
                            <!-- Thymeleaf循环语句：  th:each -->
                            <li th:each="n : ${newsList}" class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <!-- <h3 th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:mm')}"></h3>-->
                                    <p>
                                    <h3 style="color: orange" th:text="${n.title}"></h3>
                                    <span th:text="${n.publishby}" class="layui-badge layui-bg-blue"></span>
                                    <span th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:mm')}" class="layui-badge layui-bg-green"></span>
                                    <br><span th:text="${n.content}"></span>
                                    </p>
                                </div>
                            </li>
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">更多......</div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['carousel', 'form'], function () {
        var carousel = layui.carousel
            , form = layui.form;

        //常规轮播
        carousel.render({
            elem: '#test1'
            , arrow: 'always'
            , height: '280px'
            , width: '450px'
        });
    });
</script>

<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    // window.dataList = [];
    var datalist = [];
    option = {
        tooltip: {
            triggerOn: "click",
            formatter: function (e, t, n) {
                return '.5' == e.value ? e.name + "：有疑似病例" : e.seriesName + "<br />" + e.name + "：" + e.value
            }
        },
        toolbox: {
            show: true,
            orient: 'vertical',
            left: 'right',
            top: 'center',
            feature: {
                dataView: {readOnly: false},
                restore: {},
                saveAsImage: {}
            }
        }, // 提供下载工具
        visualMap: {
            min: 0,
            max: 100000,
            left: 26,
            bottom: 90,
            showLabel: !0,
            text: ["高", "低"],
            pieces: [{
                gt: 10000,
                label: "> 10000人",
                color: "#7f1100"
            }, {
                gte: 5000,
                lte: 10000,
                label: "5000 - 10000人",
                color: "#3325c2"
            }, {
                gte: 1000,
                lte: 5000,
                label: "1000 - 5000人",
                color: "#ff3f3c"
            }, {
                gte: 100,
                lt: 1000,
                label: "100 - 1000人",
                color: "#ffb74a"
            }, {
                gt: 10,
                lt: 100,
                label: "10 - 100人",
                color: "#fff48c"
            }, {
                gt: 0,
                lt: 10,
                label: "0 - 10人",
                color: "#aaf97c"
            }
            ],
            show: !0
        },
        geo: {
            map: "china",
            roam: !1,
            scaleLimit: {
                min: 1,
                max: 2
            },
            zoom: 1.23,
            top: 80,
            label: {
                normal: {
                    show: !0,
                    fontSize: "14",
                    color: "rgba(0,0,0,0.7)"
                }
            },
            itemStyle: {
                normal: {
                    //shadowBlur: 50,
                    //shadowColor: 'rgba(0, 0, 0, 0.2)',
                    borderColor: "rgba(0, 0, 0, 0.2)"
                },
                emphasis: {
                    areaColor: "#f2d5ad",
                    shadowOffsetX: 0,
                    shadowOffsetY: 0,
                    borderWidth: 0
                }
            }
        }
    };

    $.ajax({
        url: "/query",
        dataType: "json",
        success: function (data) {
            for (let i in data) {
                datalist[i] = data[i];
            }
            myChart.setOption({
                series: [
                    {
                        name: "现有确诊",
                        type: "map",
                        geoIndex: 0,
                        data: datalist
                    }
                ]
            })
        }
    });

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>

</body>
</html>